package keyValueBaseInterfaces;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import assignmentImplementation.KeyImpl;

@XmlRootElement(name="pair")
public class Pair<K, V> implements Comparable<Pair<K, V>> {
	
	@XmlElement(name="k")
	private K k;
	@XmlElement(name="v")
	private V v;
	
	@SuppressWarnings("unused")
	private Pair()
	{
	}
	
	public Pair (K k, V v){
		this.k = k;
		this.v = v;
	}
	
	public K getKey(){
		return k;
	}
	
	public V getValue(){
		return v;
	}
	
	public int compareTo(Pair<K, V> p){
		if(this.getKey().getClass() == KeyImpl.class && p.getKey().getClass() == KeyImpl.class)
		{
			return ((KeyImpl) k).compareTo(((KeyImpl) p.getKey()));
		}
		return 0;
	}
}
